package com.zy.algorithm;

import com.google.common.collect.Lists;
import com.zy.algorithm.model.Heap;
import com.zy.algorithm.sort.SortFactory;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author ZhaoYi
 * @date 2023/11/13 14:49
 */
public class Main {
    public static void main(String[] args) {


        //排序
        //List<Integer> insertionSortList = Lists.newArrayList(2,3,5,2,6);
        List<Integer> insertionSortList = getRandomList(28);
        Object[] objects = Arrays.copyOf(insertionSortList.toArray(), insertionSortList.size());
        //List insertionSort = SortFactory.get("BubblingSort").sort(insertionSortList);
        //List insertionSort = SortFactory.get("SelectionSort").sort(insertionSortList);
        //List insertionSort = SortFactory.get("InsertionSort").sort(insertionSortList);
        /*List<Integer> insertionSort = SortFactory.get("QuickSort").sort(insertionSortList);

        String result = Arrays.toString(insertionSort.toArray());
        System.out.println("排序结果: " + result);

        Arrays.sort(objects);
        String good = Arrays.toString(objects);
        System.out.println("标准结果: " + good);
        System.out.println("是否正确: " + good.equals(result));*/

        Heap<Integer> integerHeap = new Heap<>();
        integerHeap.add(0);
        integerHeap.add(1);
        integerHeap.add(2);
        integerHeap.add(3);
        integerHeap.add(6);
        integerHeap.add(4);
        integerHeap.printHeap();



    }

    private static List<Integer> getRandomList(int randomNumber) {
        // 生成随机正整数
        List<Integer> ls = Lists.newArrayListWithCapacity(randomNumber);
        for (int i = 0; i < randomNumber; i++) {
            ls.add(ThreadLocalRandom.current().nextInt(1000));
        }
        System.out.println("随机数组:" + Arrays.toString(ls.toArray()));
        return ls;
    }
}